package com.sunjob.mroresource.mapper;

import com.mysql.cj.log.Log;
import com.sunjob.common.domain.resource.ToolEntity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import javax.swing.*;
import java.util.List;

@Mapper
@Repository
public interface ToolMapper {
    //新增
    @Insert("insert into tool values" +
            " (#{id},#{name},#{model},#{gg},#{uni},#{stock},#{storearea},#{vender},#{area},#{url},#{species_id},#{status_id},#{inorout_id},#{vehicletype_id} )")
    @Results({
            @Result(property ="id",column="tool_id"),
            @Result(property ="name",column="tool_name"),
            @Result(property ="model",column="tool_model"),
            @Result(property ="gg",column="tool_specification"),
            @Result(property ="uni",column="tool_uni"),
            @Result(property ="stock",column="tool_stock"),
            @Result(property ="storearea",column=" tool_storearea"),
            @Result(property ="vender",column="tool_vender"),
            @Result(property ="area",column=" tool_area"),
            @Result(property ="url",column="img_url"),
            @Result(property ="species_id",column="tool_species_id"),
            @Result(property ="status_id",column=" tool_status_id"),
            @Result(property ="inorout_id",column="inorout_id"),
            @Result(property ="vehicletype_id",column=" vehicletype_id")
    })
    int  addTool(ToolEntity toolEntity);
    //查询
    @Select("select *from tool")
    @Results({
            @Result(property ="id",column="tool_id"),
            @Result(property ="name",column="tool_name"),
            @Result(property ="model",column="tool_model"),
            @Result(property ="gg",column="tool_specification"),
            @Result(property ="uni",column="tool_uni"),
            @Result(property ="stock",column="tool_stock"),
            @Result(property ="storearea",column=" tool_storearea"),
            @Result(property ="vender",column="tool_vender"),
            @Result(property ="area",column=" tool_area"),
            @Result(property ="url",column="img_url"),
            @Result(property ="species_id",column="tool_species_id"),
            @Result(property ="status_id",column=" tool_status_id"),
            @Result(property ="inorout_id",column="inorout_id"),
            @Result(property ="vehicletype_id",column=" vehicletype_id")
    })
    List<ToolEntity> liasTool();
    //修改
    @Update("update tool set  tool_status_id = 0 where tool_id=#{status_id} ")
    @Results({
            @Result(property ="id",column="tool_id"),
            @Result(property ="name",column="tool_name"),
            @Result(property ="model",column="tool_model"),
            @Result(property ="gg",column="tool_specification"),
            @Result(property ="uni",column="tool_uni"),
            @Result(property ="stock",column="tool_stock"),
            @Result(property ="storearea",column=" tool_storearea"),
            @Result(property ="vender",column="tool_vender"),
            @Result(property ="area",column=" tool_area"),
            @Result(property ="url",column="img_url"),
            @Result(property ="species_id",column="tool_species_id"),
            @Result(property ="status_id",column=" tool_status_id"),
            @Result(property ="inorout_id",column="inorout_id"),
            @Result(property ="vehicletype_id",column=" vehicletype_id")
    })
    int uqdatetool(long status_id);

    //删除是修改了工具的状态
    @Update("update tool set  tool_status_id = 0 where tool_id=#{status_id} ")
    @Results({
            @Result(property ="id",column="tool_id"),
            @Result(property ="name",column="tool_name"),
            @Result(property ="model",column="tool_model"),
            @Result(property ="gg",column="tool_specification"),
            @Result(property ="uni",column="tool_uni"),
            @Result(property ="stock",column="tool_stock"),
            @Result(property ="storearea",column=" tool_storearea"),
            @Result(property ="vender",column="tool_vender"),
            @Result(property ="area",column=" tool_area"),
            @Result(property ="url",column="img_url"),
            @Result(property ="species_id",column="tool_species_id"),
            @Result(property ="status_id",column=" tool_status_id"),
            @Result(property ="inorout_id",column="inorout_id"),
            @Result(property ="vehicletype_id",column=" vehicletype_id")
    })
    int deletetool(long status_id);
    //根据id查找所有
    @Select("select tool_id, tool_name,tool_model,tool_specification, tool_uni,tool_stock,tool_storearea,tool_vender,tool_area from tool where tool_id={id}")
    @Results({
            @Result(property ="id",column="tool_id"),
            @Result(property ="name",column="tool_name"),
            @Result(property ="model",column="tool_model"),
            @Result(property ="gg",column="tool_specification"),
            @Result(property ="uni",column="tool_uni"),
            @Result(property ="stock",column="tool_stock"),
            @Result(property ="storearea",column=" tool_storearea"),
            @Result(property ="vender",column="tool_vender"),
            @Result(property ="area",column=" tool_area"),
            @Result(property ="url",column="img_url"),
            @Result(property ="species_id",column="tool_species_id"),
            @Result(property ="status_id",column=" tool_status_id"),
            @Result(property ="inorout_id",column="inorout_id"),
            @Result(property ="vehicletype_id",column=" vehicletype_id")
    })
    List<ToolEntity> listtoolId(ToolEntity toolEntity);
    //根据名字查找
    @Select("select tool_id, tool_name,tool_model,tool_specification, tool_uni,tool_stock,tool_storearea,tool_vender,tool_area from tool where tool_name={name}")
    @Results({
            @Result(property ="id",column="tool_id"),
            @Result(property ="name",column="tool_name"),
            @Result(property ="model",column="tool_model"),
            @Result(property ="gg",column="tool_specification"),
            @Result(property ="uni",column="tool_uni"),
            @Result(property ="stock",column="tool_stock"),
            @Result(property ="storearea",column=" tool_storearea"),
            @Result(property ="vender",column="tool_vender"),
            @Result(property ="area",column=" tool_area"),
            @Result(property ="url",column="img_url"),
            @Result(property ="species_id",column="tool_species_id"),
            @Result(property ="status_id",column=" tool_status_id"),
            @Result(property ="inorout_id",column="inorout_id"),
            @Result(property ="vehicletype_id",column=" vehicletype_id")
    })
    List<ToolEntity> listtoolName(ToolEntity toolEntity);
    //根据型号查找
    @Select("select tool_id, tool_name,tool_model,tool_specification, tool_uni,tool_stock,tool_storearea,tool_vender,tool_area from tool where tool_model={model}")
    @Results({
            @Result(property ="id",column="tool_id"),
            @Result(property ="name",column="tool_name"),
            @Result(property ="model",column="tool_model"),
            @Result(property ="gg",column="tool_specification"),
            @Result(property ="uni",column="tool_uni"),
            @Result(property ="stock",column="tool_stock"),
            @Result(property ="storearea",column=" tool_storearea"),
            @Result(property ="vender",column="tool_vender"),
            @Result(property ="area",column=" tool_area"),
            @Result(property ="url",column="img_url"),
            @Result(property ="species_id",column="tool_species_id"),
            @Result(property ="status_id",column=" tool_status_id"),
            @Result(property ="inorout_id",column="inorout_id"),
            @Result(property ="vehicletype_id",column=" vehicletype_id")
    })
    List<ToolEntity> listtoolModel(ToolEntity toolEntity);

    @Select("select tool_id, tool_name,tool_model,tool_specification, tool_uni,tool_stock,tool_storearea,tool_vender,tool_area from tool where tool_specification={gg}")
    @Results({
            @Result(property ="id",column="tool_id"),
            @Result(property ="name",column="tool_name"),
            @Result(property ="model",column="tool_model"),
            @Result(property ="gg",column="tool_specification"),
            @Result(property ="uni",column="tool_uni"),
            @Result(property ="stock",column="tool_stock"),
            @Result(property ="storearea",column=" tool_storearea"),
            @Result(property ="vender",column="tool_vender"),
            @Result(property ="area",column=" tool_area"),
            @Result(property ="url",column="img_url"),
            @Result(property ="species_id",column="tool_species_id"),
            @Result(property ="status_id",column=" tool_status_id"),
            @Result(property ="inorout_id",column="inorout_id"),
            @Result(property ="vehicletype_id",column=" vehicletype_id")
    })
    Object listtoolStorearea();

    @Select("select tool_id, tool_name,tool_model,tool_specification, tool_uni,tool_stock,tool_storearea,tool_vender,tool_area from tool where tool_vender={vender}")
    @Results({
            @Result(property ="id",column="tool_id"),
            @Result(property ="name",column="tool_name"),
            @Result(property ="model",column="tool_model"),
            @Result(property ="gg",column="tool_specification"),
            @Result(property ="uni",column="tool_uni"),
            @Result(property ="stock",column="tool_stock"),
            @Result(property ="storearea",column=" tool_storearea"),
            @Result(property ="vender",column="tool_vender"),
            @Result(property ="area",column=" tool_area"),
            @Result(property ="url",column="img_url"),
            @Result(property ="species_id",column="tool_species_id"),
            @Result(property ="status_id",column=" tool_status_id"),
            @Result(property ="inorout_id",column="inorout_id"),
            @Result(property ="vehicletype_id",column=" vehicletype_id")
    })
    Object listtoolVender();

    @Select("select tool_id, tool_name,tool_model,tool_specification, tool_uni,tool_stock,tool_storearea,tool_vender,tool_area from tool where tool_area={area}")
    @Results({
            @Result(property ="id",column="tool_id"),
            @Result(property ="name",column="tool_name"),
            @Result(property ="model",column="tool_model"),
            @Result(property ="gg",column="tool_specification"),
            @Result(property ="uni",column="tool_uni"),
            @Result(property ="stock",column="tool_stock"),
            @Result(property ="storearea",column=" tool_storearea"),
            @Result(property ="vender",column="tool_vender"),
            @Result(property ="area",column=" tool_area"),
            @Result(property ="url",column="img_url"),
            @Result(property ="species_id",column="tool_species_id"),
            @Result(property ="status_id",column=" tool_status_id"),
            @Result(property ="inorout_id",column="inorout_id"),
            @Result(property ="vehicletype_id",column=" vehicletype_id")
    })
    Object listtoolArea();

    @Select("select tool_id, tool_name,tool_model,tool_specification, tool_uni,tool_stock,tool_storearea,tool_vender,tool_area ,tool_species_id, tool_status_id,inorout_id,vehicletype_id from tool where tool_species_id={species_id}")
    @Results({
            @Result(property ="id",column="tool_id"),
            @Result(property ="name",column="tool_name"),
            @Result(property ="model",column="tool_model"),
            @Result(property ="gg",column="tool_specification"),
            @Result(property ="uni",column="tool_uni"),
            @Result(property ="stock",column="tool_stock"),
            @Result(property ="storearea",column=" tool_storearea"),
            @Result(property ="vender",column="tool_vender"),
            @Result(property ="area",column=" tool_area"),
            @Result(property ="url",column="img_url"),
            @Result(property ="species_id",column="tool_species_id"),
            @Result(property ="status_id",column=" tool_status_id"),
            @Result(property ="inorout_id",column="inorout_id"),
            @Result(property ="vehicletype_id",column=" vehicletype_id")
    })
    Object listtoolspecies_id();

    @Select("select tool_id, tool_name,tool_model,tool_specification, tool_uni,tool_stock,tool_storearea,tool_vender,tool_area ,tool_species_id, tool_status_id,inorout_id,vehicletype_id from tool where vehicletype_id={vehicletype_id}")
    @Results({
            @Result(property ="id",column="tool_id"),
            @Result(property ="name",column="tool_name"),
            @Result(property ="model",column="tool_model"),
            @Result(property ="gg",column="tool_specification"),
            @Result(property ="uni",column="tool_uni"),
            @Result(property ="stock",column="tool_stock"),
            @Result(property ="storearea",column=" tool_storearea"),
            @Result(property ="vender",column="tool_vender"),
            @Result(property ="area",column=" tool_area"),
            @Result(property ="url",column="img_url"),
            @Result(property ="species_id",column="tool_species_id"),
            @Result(property ="status_id",column=" tool_status_id"),
            @Result(property ="inorout_id",column="inorout_id"),
            @Result(property ="vehicletype_id",column=" vehicletype_id")
    })
    Object listtoolvehicletype();



}
